/*
 * Copyright(c) 2024 长沙市希尚网络科技有限公司
 * 注意：本内容仅限于长沙市希尚网络科技有限公司内部传阅，禁止外泄以及用于其他的商业目的
 */

package org.example.security.core;

import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * TODO
 *
 * @author liuy
 * @version 1.0 2024/11/14 0014
 */
@Service
public class UserDetailsServiceImpl implements UserDetailsService {

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

        // 假如这里是通过数据库获取到的用户信息，为了方便直接写死了
        if (username.equals("admin")) {
            RealUserModel userDetailItem = new RealUserModel();
            UserDTO userDTO = new UserDTO();
            userDTO.setUsername("admin").setPassword("$2a$10$oJFL87V/.bjeMQ1a6GVSt.lLxPu4WEqubpgnPK4tXyDzdp49VF9e2");
            userDetailItem.setUserDTO(userDTO);
            return userDetailItem;
        }
        throw new UsernameNotFoundException("用户名或密码错误");
    }


    public static void main(String[] args) {
        System.out.println(1|2);
    }
}
